class node():
    def __init__(self,x=-1):
        self.data=x
        self.prev=None
        self.next=None

class linked_list_sentinel():
    def __init__(self):
        self.sentinel=node()
        self.sentinel.prev=self.sentinel
        self.sentinel.next=self.sentinel
    def insert(self,x):
        a=node(x)
        a.next=self.sentinel.next
        a.next.prev=a
        self.sentinel.next=a
        a.prev=self.sentinel
    def search(self,k):
        current=self.sentinel.next
        while current!=self.sentinel and current.data!=k:
            current=current.next
        return current
    def delete(self,n): #n是要删除的节点
        n.prev.next=n.next
        n.next.prev=n.prev
        
    def lookatme(self):
        current=self.sentinel.next
        while current!=self.sentinel:
            print current.data, 
            current=current.next
        print

if __name__=='__main__':
    a=linked_list_sentinel()
    for i in range(10):
        a.insert(i+1)
    a.lookatme()
    a.delete(a.search(10))
    a.lookatme()
        
